package com.ysx.student.fangyahao.day20210910.studentmanagement.client;


import com.ysx.student.fangyahao.day20210910.studentmanagement.entity.ScoreEntity;
import com.ysx.student.fangyahao.day20210910.studentmanagement.entity.StundentEntity;
import com.ysx.student.fangyahao.day20210910.studentmanagement.service.StudentService;


import java.util.Scanner;

public class StudentTest {

    public static StudentService service = new StudentService();

    public static void main(String[] args) {

        addStudentTest();

        // deleteStudentTest();
        // addScoreTest();
        // printAllStudentTest();
        // changeScoreTest();
        // getStudentByMaxScoreOfMathsTest();

        // getStudentByMaxAverageTest();
        // sortStudentByAverageTest();
        test();
    }

    public static void test(){
        while(true){
            System.out.println("请选择: 1 登录 2 注册");
            Scanner sc = new Scanner(System.in);
            int option=sc.nextInt();
            if(option==1){
                System.out.println("请输入用户名:");
                String name = sc.next();
                System.out.println("请输入密码:");
                String password = sc.next();
                if(service.matchStudent(name,password)){
                    break;
                }else{
                    System.out.println("用户名或密码错误");
                    continue;
                }

            }else if(option==2){
                System.out.println("请输入用户名:");
                String registName = sc.next();
                System.out.println("请输入密码:");
                String registPassword = sc.next();
                service.addStudent(new StundentEntity(registName,registPassword));
            }else{
                System.out.println("选择错误");
            }
        }
    }

    public static void init(){

        service.addStudent(new StundentEntity("张三","123456",new ScoreEntity(80,75,60))) ;
        service.addStudent(new StundentEntity("李四","123456",new ScoreEntity(82,85,76))) ;
        service.addStudent(new StundentEntity("王五","123456",new ScoreEntity(78,65,65))) ;
        service.addStudent(new StundentEntity("赵六","123456")) ;
        service.addStudent(new StundentEntity("洪七","123456")) ;
    }

    public static void addStudentTest(){
        init();
    }



    public static void deleteStudentTest(){
        boolean flag;
        flag= service.deleteStudent("张三");
        flag= service.deleteStudent("张3");
        flag= service.deleteStudent("李四");
        flag= service.deleteStudent("洪七");
    }

    public static void addScoreTest(){
        boolean flag;
        flag= service.addScore("赵6",new ScoreEntity(100,80,99));
        flag= service.addScore("赵六",new ScoreEntity(90,80,99));
        flag= service.addScore("洪七",new ScoreEntity(91,88,79));
    }

    public static void changeScoreTest(){
        boolean flag;
        flag= service.changeMathsScore("张3",80);
        flag= service.changeMathsScore("张三",80);

    }

    public static void printAllStudentTest(){
        service.printAllStudent();
    }

    public static void getStudentByMaxScoreOfMathsTest(){
        service.getStudentByMaxScoreOfMaths();
    }



    public static void getStudentByMaxAverageTest(){
        service.getStudentByMaxAverage();
    }

    public static void sortStudentByAverageTest(){
        service.sortStudentByAverage();
    }


}
